/**
 * 20220712:1.rewrite with typescript
 */

/**
 * event types
 */
 class EventConfig{
    /**3d components prepared */
    public static readonly prepared:string='prepared';

    /**reset scene */
    public static readonly resetScene:string='resetScene';

    /**reset sight */
    public static readonly resetSight:string='resetSight';

    /**shift scene */
    public static readonly shiftScene:string='shiftScene';

    /**events for ui->3d */
    public static readonly uiOperate:string='uiOperate';

    /**events for 3d->ui */
    public static readonly feedback:string='feedback';

    /**lock screen area */
    public static readonly lockScreen:string='lockScreen';

    /**user gesture */
    public static readonly userGesture:string='userGesture';
}

//....................................................................

class ResetSightEventParas{
    public description:string|null;
    constructor(description:string|null){
        this.description=description;
    }
}
class ResetSightEventObject{
    public readonly type:string=EventConfig.resetSight;
    public readonly paras:ResetSightEventParas=new ResetSightEventParas(null);
    constructor(description:string|null){
        this.paras.description=description;
    }
}
interface ResetSightHandle{
    (eventObject:ResetSightEventObject):void;
}

//....................................................................

class ResetSceneEventParas{
    public description:string|null;
    constructor(description:string|null){
        this.description=description;
    }
}
class ResetSceneEventObject{
    public readonly type:string=EventConfig.resetScene;
    public readonly paras:ResetSceneEventParas=new ResetSceneEventParas(null);
    constructor(description:string|null){
        this.paras.description=description;
    }
}
interface ResetSceneHandle{
    (eventObject:ResetSceneEventObject):void;
}

//....................................................................

class UserGestureEventParas{
    public description:string|null;
    constructor(description:string|null){
        this.description=description;
    }
}
class UserGestureEventObject{
    public readonly type:string=EventConfig.userGesture;
    public readonly paras:UserGestureEventParas=new UserGestureEventParas(null);
    constructor(description:string|null){
        this.paras.description=description;
    }
}
interface UserGestureHandle{
    (eventObject:UserGestureEventObject):void;
}

//...................................................................

class LockScreenEventParas{
    public value:boolean;
    constructor(value:boolean){
        this.value=value;
    }
}
class LockScreenEventObject{
    public readonly type:string=EventConfig.lockScreen;
    public readonly paras:LockScreenEventParas=new LockScreenEventParas(false);
    constructor(value:boolean){
        this.paras.value=value;
    }
}
interface LockScreenHandle{
    (eventObject:LockScreenEventObject):void;
}

//......................................................................

class PreparedEventParas{
    public description:string|null;
    constructor(description:string|null){
        this.description=description;
    }
}
class PreparedEventObject{
    public readonly type:string=EventConfig.prepared;
    public readonly paras:PreparedEventParas=new PreparedEventParas(null);
    constructor(description:string|null){
        this.paras.description=description;
    }
}
interface PreparedHandle{
    (eventObject:PreparedEventObject):void;
}

//.....................................................................

class FeedbackEventParas<T>{
    public description:string;
    public value:T|null;
    constructor(description:string,value:T|null){
        this.description=description;
        this.value=value;
    }
}
class FeedbackEventObject<T>{
    public readonly type:string=EventConfig.feedback;
    public readonly paras:FeedbackEventParas<T>=new FeedbackEventParas<T>('',null);
    constructor(desciption:string,value:T|null){
        this.paras.description=desciption;
        this.paras.value=value;
    }
}
interface FeedbackHandle<T>{
    (eventObject:FeedbackEventObject<T>):void;
}

//.....................................................................

class ShiftSceneEventParas{
    public current:number;
    public previous:number;
    constructor(preIndex:number,curIndex:number){
        this.current=curIndex;
        this.previous=preIndex;
    }
}
class ShiftSceneEventObject{
    public readonly type:string=EventConfig.shiftScene;
    public readonly paras:ShiftSceneEventParas=new ShiftSceneEventParas(1,0);
    constructor(pre:number,cur:number){
        this.paras.current=cur;
        this.paras.previous=pre;
    }
}; 
interface ShiftSceneHandle{
    (eventObject:ShiftSceneEventObject):void;
}

//........................................................................

class UiOperateEventParas<T>{
    public description:string;
    public value:T|null;
    constructor(description:string,value:T|null){
        this.description=description;
        this.value=value;
    }
}
class UiOperateEventObject<T>{
    public readonly type:string=EventConfig.uiOperate;
    public readonly paras:UiOperateEventParas<T|null>=new UiOperateEventParas('',null);
    constructor(desciption:string,value:T|null){
        this.paras.description=desciption;
        this.paras.value=value;
    }
}
interface UiOperateHandle<T>{
    (eventObject:UiOperateEventObject<T>):void;
}

//......................................................................
export {
    EventConfig,
    ShiftSceneEventObject,
    UiOperateEventObject,
    FeedbackEventObject, 
    PreparedEventObject,
    UserGestureEventObject,
    LockScreenEventObject,
    ResetSceneEventObject,
    ResetSightEventObject
};
export type { 
    FeedbackHandle ,
    UiOperateHandle,
    ResetSceneHandle,
    ResetSightHandle,
    ShiftSceneHandle,
    PreparedHandle,
    LockScreenHandle,
    UserGestureHandle
};
